derive Debug for more data structures
authorSiddharth Agarwal <sid0@fb.com>
Fri, 4 Aug 2017 01:45:59 +0000 (18:45 -0700)
committerSiddharth Agarwal <sid0@fb.com>
Fri, 4 Aug 2017 01:49:15 +0000 (18:49 -0700)
This makes it easier for wrappers around Cargo to inspect the contents
of these data structures.

src/cargo/core/manifest.rs
src/cargo/core/package.rs
src/cargo/core/workspace.rs
src/cargo/util/toml/mod.rs

index 662a5cbe4ce71721e697e0a6b8ada589a4d99557..75c09c5e26ea1f09ec119347956ea184c078f15d 100644 (file)
@@ -17,7 +17,7 @@ pub enum EitherManifest {
 }
 
 /// Contains all the information about a package, as loaded from a Cargo.toml.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct Manifest {
     summary: Summary,
     targets: Vec<Target>,
index bdb7f41d4c3a9cf3a0e1579f63ec5a3ebec9b621..493c2a248c05cf76f1525fb427ee249a862aea63 100644 (file)
@@ -18,7 +18,7 @@ use util::errors::{CargoResult, CargoResultExt};
 ///
 /// A package is a `Cargo.toml` file plus all the files that are part of it.
 // TODO: Is manifest_path a relic?
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct Package {
     // The package's manifest
     manifest: Manifest,
index ad53fc5b5c94ab75ceeace5a05b402c31d02a23f..148e1e9ff44824fcb938bec6ce1c5962d68c897e 100644 (file)
@@ -18,6 +18,7 @@ use util::toml::read_manifest;
 /// A workspace is often created very early on and then threaded through all
 /// other functions. It's typically through this object that the current
 /// package is loaded and/or learned about.
+#[derive(Debug)]
 pub struct Workspace<'cfg> {
     config: &'cfg Config,
 
@@ -57,11 +58,13 @@ pub struct Workspace<'cfg> {
 
 // Separate structure for tracking loaded packages (to avoid loading anything
 // twice), and this is separate to help appease the borrow checker.
+#[derive(Debug)]
 struct Packages<'cfg> {
     config: &'cfg Config,
     packages: HashMap<PathBuf, MaybePackage>,
 }
 
+#[derive(Debug)]
 enum MaybePackage {
     Package(Package),
     Virtual(VirtualManifest),
index 84eb68f6514178d0a6890e8d5a5a9d84e9626bf3..fcf5a98d1e850becd386aa2d59d44f0534d91520 100644 (file)
@@ -142,7 +142,7 @@ type TomlExampleTarget = TomlTarget;
 type TomlTestTarget = TomlTarget;
 type TomlBenchTarget = TomlTarget;
 
-#[derive(Serialize)]
+#[derive(Debug, Serialize)]
 #[serde(untagged)]
 pub enum TomlDependency {
     Simple(String),
@@ -181,7 +181,7 @@ impl<'de> de::Deserialize<'de> for TomlDependency {
     }
 }
 
-#[derive(Deserialize, Serialize, Clone, Default)]
+#[derive(Deserialize, Serialize, Clone, Debug, Default)]
 pub struct DetailedTomlDependency {
     version: Option<String>,
     path: Option<String>,
@@ -197,7 +197,7 @@ pub struct DetailedTomlDependency {
     default_features2: Option<bool>,
 }
 
-#[derive(Deserialize, Serialize)]
+#[derive(Debug, Deserialize, Serialize)]
 pub struct TomlManifest {
     package: Option<Box<TomlProject>>,
     project: Option<Box<TomlProject>>,
@@ -224,7 +224,7 @@ pub struct TomlManifest {
     badges: Option<HashMap<String, HashMap<String, String>>>,
 }
 
-#[derive(Deserialize, Serialize, Clone, Default)]
+#[derive(Deserialize, Serialize, Clone, Debug, Default)]
 pub struct TomlProfiles {
     test: Option<TomlProfile>,
     doc: Option<TomlProfile>,
@@ -233,7 +233,7 @@ pub struct TomlProfiles {
     release: Option<TomlProfile>,
 }
 
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct TomlOptLevel(String);
 
 impl<'de> de::Deserialize<'de> for TomlOptLevel {
@@ -282,7 +282,7 @@ impl ser::Serialize for TomlOptLevel {
     }
 }
 
-#[derive(Clone, Serialize)]
+#[derive(Clone, Debug, Serialize)]
 #[serde(untagged)]
 pub enum U32OrBool {
     U32(u32),
@@ -325,7 +325,7 @@ impl<'de> de::Deserialize<'de> for U32OrBool {
     }
 }
 
-#[derive(Deserialize, Serialize, Clone, Default)]
+#[derive(Deserialize, Serialize, Clone, Debug, Default)]
 pub struct TomlProfile {
     #[serde(rename = "opt-level")]
     opt_level: Option<TomlOptLevel>,
@@ -378,7 +378,7 @@ impl<'de> de::Deserialize<'de> for StringOrBool {
     }
 }
 
-#[derive(Deserialize, Serialize, Clone)]
+#[derive(Deserialize, Serialize, Clone, Debug)]
 pub struct TomlProject {
     name: String,
     version: semver::Version,
@@ -404,7 +404,7 @@ pub struct TomlProject {
     metadata: Option<toml::Value>,
 }
 
-#[derive(Deserialize, Serialize)]
+#[derive(Debug, Deserialize, Serialize)]
 pub struct TomlWorkspace {
     members: Option<Vec<String>>,
     exclude: Option<Vec<String>>,
@@ -966,7 +966,7 @@ impl ser::Serialize for PathValue {
 }
 
 /// Corresponds to a `target` entry, but `TomlTarget` is already used.
-#[derive(Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug)]
 struct TomlPlatform {
     dependencies: Option<HashMap<String, TomlDependency>>,
     #[serde(rename = "build-dependencies")]